<template>
	<div>
		<div class="h2">签到管理</div>
		<div class="option">
			<a-button type="primary" class="btn" @click="seeList('','add')">新增</a-button>
		</div>
		<div style="margin-top:10px;">
			<el-table :data="data" v-loading="loading" border :max-height="tableHeight" highlight-current-row style="width: 100%;">
				<el-table-column type="index" label="序号" width="60" fixed="left"></el-table-column>
				<el-table-column prop="TypeName" label="签到类型" width="90"></el-table-column>
				<el-table-column prop="SignNum" label="已签到人数" width="110">
					<template slot-scope="scope">
						<a-tag @click="seeList(scope.row,'signIndex')" color="blue">{{ scope.row.SignNum }}</a-tag>
					</template>
				</el-table-column>
				<el-table-column prop="NoSignNum" label="未签到人数" width="110">
					<template slot-scope="scope">
						<a-tag @click="seeList(scope.row,'noSignIndex')" color="red">{{ scope.row.NoSignNum }}</a-tag>
					</template>
				</el-table-column>
				<el-table-column prop="StartTime" label="开始时间-结束时间" min-width="280">
					<template slot-scope="scope">
						{{ scope.row.StartTime }} - {{ scope.row.EndTime }}
					</template>
				</el-table-column>
				<el-table-column prop="StartTime" label="添加人" min-width="180">
					<template slot-scope="scope">
						{{ scope.row.AddUserNo }} / {{ scope.row.AddUserName }}
					</template>
				</el-table-column>
				<el-table-column label="操作" width="90" fixed="right">
					<template slot-scope="scope">
						<a-tooltip placement="top">
							<template slot="title">修改</template>
							<i title="修改" class="iconfont icon-editor1" style="color: #1890FF;" @click="seeList(scope.row, 'add')"></i>
						</a-tooltip>
						<a-tooltip placement="top">
							<template slot="title">删除</template>
							<i title="删除" class="iconfont icon-delete" style="color: red;" @click="deleteList(scope.row)"></i>
						</a-tooltip>
					</template>
				</el-table-column>
			</el-table>
		</div>
		<addSign :text="text" v-show="addSignIf" @closeFun="closeFun"></addSign>
	</div>
</template>

<script>
import moment from 'moment';
import addSign from './addSign';
import Func from '@/utils/func';
import Cache from '@/utils/cache';
import { getActivitySignList,DeleteActivitySign } from '@/api/follow';
const data = [];
export default {
	components: {
		addSign
	},
	data() {
		return {
			data,
			addIf: false,
			text: {},
			loading: false,
			tableHeight: parseFloat(window.innerHeight - 160),
			requestUrl:this.global.requestUrl,
			token:Cache.get('token'),
			addSignIf:false
		};
	},
	computed: {},
	created() {
		this.getList();
		// this.getOtherList();
	},
	mounted() {},
	methods: {
		moment,
		async getList() {
			this.loading = true;
			let data = {};
			data.activityID = this.$route.query.ID ? this.$route.query.ID : '';
			let res = await getActivitySignList(data);
			if(res.data.code!==0){
				this.$message.error(res.data.msg)
			}
			this.loading = false;
			this.data = res.data.data;
		},
		async getOtherList() {
			let res = await GetActivityStateList();
			this.ActivityStateList = res.data.data;
			let res1 = await GetDepartList();
			this.DepartCodeList = res1.data.data;
		},
		deleteList(text) {
			let that = this;
			this.$confirm({
				title: '提示',
				content: `您确定删除该活动签到吗？`,
				okText: '确认',
				cancelText: '取消',
				async onOk() {
					let data = {};
					data.id = text.ID;
					let res = await DeleteActivitySign(data);
					if (res.data.code == 0) {
						that.getList();
						that.$message.success(res.data.msg);
					} else {
						that.$message.error(res.data.msg);
					}
				}
			});
		},
		seeList(text, name) {
			if (name == 'add') {
				this.text = {time:new Date(),ActivityID:this.$route.query.ID,...text}
				this.addSignIf = true
			}else{
				this.$router.push({
					name: name,
					query: {
						ID: text.ID
					}
				});
			}
		},
		closeFun(data) {
			this.addSignIf = false;
			if(data==1){
				this.getList();
			}
		}
	}
};
</script>

<style lang="less" scoped>
/deep/.ant-form-item {
	display: flex;
	margin-bottom: 10px !important;
}
/deep/.ant-form-item-label {
	width: 80px;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	text-align: right;
}
/deep/.ant-form-item-control-wrapper {
	flex: 1;
}
/deep/.el-table th.is-leaf {
	background: #fafafa;
}
/deep/.el-table td,
/deep/.el-table th {
	padding: 5px;
}
.option {
	margin-top: 10px;
	margin-bottom: 20px;
	overflow: hidden;
}
.option .btn {
	height: 36px;
	line-height: 36px;
	padding: 0 10px;
	float: left;
	background: #1890ff;
	color: #fff;
	margin-right: 10px;
	border-radius: 3px;
	cursor: pointer;
	border: none;
}
.foot {
	text-align: center;
	margin-top: 100px;
}
.el-pagination {
	margin-top: 10px;
}
</style>
